{% extends "my/layout.html" %}

{% block my %}
<div class="container">
    <h3>订购SS</h3>
    <hr>


    <div class="row">
        <div class="col-xs-3">
            <a href="javascript:void(0);" class="btn btn-success btn-month" data-value="2" data-url="{{url_for('over.handlers.my.cart.add')}}">加入购物车(8元/月)</a>
        </div>
        <div class="col-xs-2">
            <a href="javascript:void(0);" class="btn btn-success btn-year" data-value="1"  data-url="{{url_for('over.handlers.my.cart.add')}}">加入购物车(68元/年)</a>
        </div>

    </div>


</div>
{% endblock %}

{% block script %}
<script type="text/javascript">
    $(function () {
        var cancelOrder = function (orderNum) {
            $.post("{{url_for('over.handlers.my.order.cancel')}}", {orderNum: orderNum}).done(function (data) {
                if (data.success) {
                    window.location.reload();
                } else {
                    alert(data.error);
                }
            });
        };

        var payOrder = function (orderNum) {
            $.post('{{url_for("over.handlers.my.order.pay")}}', {orderNum: orderNum}).done(function (data) {
                if (data.success) {
                    window.location.reload();
                } else {
                    alert(data.error);
                }
            });
        };


        $(".btn-cancel-order").click(function () {
            var $this = $(this);
            var orderNum = $this.attr("data-value");

            cancelOrder(orderNum);
        });

        $(".btn-pay-order").click(function () {
            var $this = $(this);
            var orderNum = $this.attr("data-value");

            payOrder(orderNum);
        });

    })

</script>
{% endblock %}